/**
 * 创建于：2016-5-23
 * 创建人：杨骐彰
 * 说明：table组件
 */
import {Table} from 'antd'
import React from 'react'
import './ant-table.scss'
import 'antd/lib/pagination/style/css'
import 'antd/lib/spin/style/css'
import 'antd/lib/checkbox/style/css'


//表格

const  AntTable = (props)=>{
  let {align,pagination,showHeader,
    title,columns,data,isLoading,bordered,onChange,rowSelection,locale,scroll,pageSize,currentPage
  } = props;
  let page = (typeof pagination ==='object')?pagination:(pagination?
    ({
      pageSize: pageSize,
      defaultPageSize:5,
      showSizeChanger: true,
      showQuickJumper:true,
      showTotal:(total, range) => `共${total}条记录，每页${pageSize}条记录，当前显示第${currentPage}页`
    }): false);
  let border = bordered!==false;
  if(title) {
    return (
      <Table
        title={()=>{return title}}
        showHeader={showHeader}
        columns ={columns}
        dataSource ={data}
        loading={isLoading}
        bordered={border}
        onChange={onChange}
        rowSelection={rowSelection}
        pagination={page}
        locale={locale}
        scroll={scroll}
      />
    )
  } else {
    return (
      <Table
        showHeader={showHeader}
        columns ={columns}
        dataSource ={data}
        loading={isLoading}
        bordered={border}
        onChange={onChange}
        rowSelection={rowSelection}
        pagination={page}
        locale={locale}
        scroll={scroll}
      />
    )
  }
}

module.exports = AntTable

